What does [a|b|c] evaluate to in Prolog?

Posted by Ambrose on Stack Overflow See other posts from Stack Overflow or by Ambrose
Published on 2010-06-03T15:00:33Z Indexed on 2010/06/03 15:04 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

The pipe operator in prolog returns one or more atomic Heads and a Tail list.

?- [a,b,c] = [a,b|[c]].
true.

Nesting multiple pipes in a single match can be done similar to this:

?- [a,b,c] = [a|[b|[c]]].
true.

What does the statement [a|b|c] infer about a, b and c?

© Stack Overflow or respective owner

Related posts about prolog

Related posts about pipe